#pragma once
#include "HashTable.h"

namespace wjy
{
	template<class K,class hash=Hash<K>>
	class unordered_set
	{
	public:
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};

		typedef typename LinkHash::HashLinkTable<K, K, SetKeyOfT,hash>::iterator iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}
		pair<iterator,bool> insert(const K& key)
		{
			return _ht.Insert(key);
		}
	private:
		LinkHash::HashLinkTable<K, K,SetKeyOfT,hash> _ht;
	};

	void test_unordered_set()
	{
		unordered_set<int> us;
		us.insert(4);
		us.insert(14);
		us.insert(5);
		us.insert(8);

		unordered_set<int>::iterator it = us.begin();
		while (it != us.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}